
/**
 @file sys_at_mcu.h

 @author  Copyright (C) 2019 Centec Networks Inc.  All rights reserved.

 @date 2021-08-19

 @version v0.1

*/

#ifndef _SYS_TMR_FGBU_H
#define _SYS_TMR_FGBU_H
#ifdef __cplusplus
extern "C" {
#endif

/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/


/****************************************************************
*
* Defines and Macros
*
****************************************************************/

#define SYS_TMG_MCU_NUM                11

#define SYS_TMG_MCU_SHARED_MEM_OFFSET_ADDR 0x1c400 /* offset addr 113K, 113 *1024 = 0x4001c400 */
#define SYS_TMG_MCU_SHARED_MEM_SIZE        0x3c00  /* 15K, 15 * 1024 = 0x3c00    */

#define SYS_TMG_MCU_ID_TO_CORE_ID(core_id, mcu_id)   (core_id = (mcu_id / SYS_TMG_MCU_NUM_PER_CORE))
#define SYS_TMG_MCU_ID_PER_CORE(mcu_id)   (mcu_id % SYS_TMG_MCU_NUM_PER_CORE)

#define SYS_TMG_MCUMEM_BYTES 4
#define SYS_TMG_MCUMEM_WORDS 1
#define SYS_TMG_MCU_STATS_RAM_TBL_ENTRY_NUM_PER_MCMAC 160
#define SYS_TMG_MCU_STATS_RAM_TBL_ENTRY_NUM_PER_BLOCK 40

#define HW_LOCK_PORT_MAPPING_GRANT_ID     0
#define HW_LOCK_PORT_MAPPING_BIT_OF_GRANT 0

/*
 * grand_id : 0 - 7
 * bit      : 0 - 31
 */
#define TMG_MCU_MAX_GRAND_ID     7
#define TMG_MCU_MAX_GRAND_BIT_ID 31

#define PORT_MAPPING_HW_LOCK(lchip, mcu_id)   CTC_ERROR_RETURN(sys_tmg_mcu_hw_lock(lchip, mcu_id, HW_LOCK_PORT_MAPPING_GRANT_ID, HW_LOCK_PORT_MAPPING_BIT_OF_GRANT))
#define PORT_MAPPING_HW_UNLOCK(lchip, mcu_id) CTC_ERROR_RETURN(sys_tmg_mcu_hw_unlock(lchip, mcu_id, HW_LOCK_PORT_MAPPING_GRANT_ID, HW_LOCK_PORT_MAPPING_BIT_OF_GRANT))

struct sys_tmg_mcu_dmps_msg_header_s
{
    uint32 type      :8;
    uint32 id        :8;
    uint32 data_len :16;
};
typedef struct sys_tmg_mcu_dmps_msg_header_s sys_tmg_mcu_dmps_msg_header_t;

struct sys_tmg_mcu_port_mapping_s
{
    uint32 dport        :16;
    uint32 psd_lane_bmp :8;
    uint32 if_mode      :5;
    uint32 an_fec       :3;
    uint32 ocs          :8;
    uint32 an_psd       :16;
    uint32 rsv          :8;
};
typedef struct sys_tmg_mcu_port_mapping_s sys_tmg_mcu_port_mapping_t;

/* API */
int32
sys_tmg_mcu_init(uint8 lchip);
int32
sys_tmg_mcu_del_port_mapping(uint8 lchip, uint16 dport);
int32
sys_tmg_mcu_add_port_mapping(uint8 lchip, uint16 dport);


#ifdef __cplusplus
}
#endif

#endif



